1
bash
This code reads the contents of file.txt
, stores them in a variable, and prints the contents with custom text before and after, using echo
with the -e
flag to interpret newline characters.
Contents=$(cat file.txt) # "\n" prints a new line character # "-e" to interpret the newline escape characters as escape characters echo -e "START OF FILE\n$Contents\nEND OF FILE" # => START OF FILE # => [contents of file.txt] # => END OF FILE
bash internalfile and stream operationsfile readingreading file contents